package com.irdstudio.efp.console.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.console.service.dao.PrdChangeRecordDao;
import com.irdstudio.efp.console.service.domain.PrdChangeRecord;
import com.irdstudio.efp.console.service.facade.PrdChangeRecordService;
import com.irdstudio.efp.console.service.vo.PrdChangeRecordVO;
/**
 * <p>ServiceImpl: 产品变更记录表				<p>
 * @author liuxp
 * @date 2018-08-2
 */
@Service("prdChangeRecordService")
public class PrdChangeRecordServiceImpl implements PrdChangeRecordService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(PrdChangeRecordServiceImpl.class);

	@Autowired
	private PrdChangeRecordDao prdChangeRecordDao;
	
	
	@Override
	public int insertPrdChangeRecord(PrdChangeRecordVO prdChangeRecordVo) {
		logger.debug("当前新增数据为:"+ prdChangeRecordVo.toString());
		int num = 0;
		try {
			PrdChangeRecord prdChangeRecord = new PrdChangeRecord();
			beanCopy(prdChangeRecordVo, prdChangeRecord);
			num = prdChangeRecordDao.insertPrdChangeRecord(prdChangeRecord);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	@Override
	public List<PrdChangeRecordVO> queryAllByBizSerno(PrdChangeRecordVO inPrdChangeRecordVo) {
		logger.debug("根据流水号查询产品申请规则关联信息的参数信息为:");
		List<PrdChangeRecordVO> list = null;
		try {
			List<PrdChangeRecord> prdApplyRules = prdChangeRecordDao.queryAllByBizSerno(inPrdChangeRecordVo);
			logger.debug("根据流水号查询产品申请规则关联信息的结果集数量为:"+ prdApplyRules.size());
			pageSet(prdApplyRules, inPrdChangeRecordVo);
			list = (List<PrdChangeRecordVO>) beansCopy(prdApplyRules, PrdChangeRecordVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}
		
		return list;
	}

	@Override
	public int deleteByBizSerno(PrdChangeRecordVO prdChangeRecordVo) {
		logger.debug("当前删除数据条件为:"+ prdChangeRecordVo);
		int num = 0;
		try {
			PrdChangeRecord prdChangeRecord = new PrdChangeRecord();
			beanCopy(prdChangeRecordVo, prdChangeRecord);
			num = prdChangeRecordDao.deleteByBizSerno(prdChangeRecord);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ prdChangeRecordVo +"删除的数据条数为"+ num);
		return num;
	}
	

	
}
